package com.rtech.app.client;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import com.rtech.model.File;

public class MainClient {

	public static void main(String[] args) {

		ApplicationContext context = new ClassPathXmlApplicationContext(
				"client-appConfig.xml");
		RestTemplate restTemplate = (RestTemplate) context
				.getBean("restTemplate");
		System.out.println("Check -- " + restTemplate);

		String filePath = "a1";
		
		String url1 = "http://10.129.11.36:8081/RuTest/file/a1.txt";
		String url2 = "http://10.129.11.36:8081/RuTest/file";
		
		try {
			
			File data = (File) restTemplate.getForObject(url2+"/{filePath}", File.class, filePath);
			System.out.println("data - " + data);
			System.out.println(data.isExist());
			System.out.println(data.getName());
			System.out.println(data.getPermissions());
			
		} catch(Exception e) {
			System.out.println("ERROR");
		}
		
		System.out.println("DONE");
		
	}
}
